import axios from "axios";

export const teacherInstance = axios.create({
    baseURL: 'http://localhost:8081/',
    timeout: 1000,
});

// 请求拦截器
teacherInstance.interceptors.request.use(
    (config) => {
        localStorage.getItem("teacher_token") && (config.headers.set("token", localStorage.getItem("teacher_token")));
        return config;
    },
    (error) => {
        // 对请求错误做些什么
        return Promise.reject(error);
    }
);

export const studentInstance = axios.create({
    baseURL: 'http://localhost:8081/',
    timeout: 1000,
});

// 请求拦截器
studentInstance.interceptors.request.use(
    (config) => {
        localStorage.getItem("student_token") && (config.headers.set("token", localStorage.getItem("student_token")));
        return config;
    },
    (error) => {
        // 对请求错误做些什么
        return Promise.reject(error);
    }
);

export const commonInstance = axios.create({
    baseURL: 'http://localhost:8081/',
    timeout: 1000,
});




